////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                           BailterRay                                       //
//                    Pip Robbins & Zhao Zhang                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
class BailterRay_GooAdvancedHardTurret extends BailterRay_GooTurret
                     placeable;

var rotator CurrentAim;
var bool bRotateClockWise;
var bool bWaiting;

const ROTATION_SPEED	      = 15000;

simulated function Tick(float DeltaTime)
{
   local BailterRayPawn PC;
   local rotator IntendedAim;

   if(!PlayerCanSeeMe())
       return;

   forEach VisibleCollidingActors(class'BailterRayPawn', PC, 640)
   {
       if(PC.IsHumanControlled())
       {
         break;
       }
   }

   if(PC != none && PC.IsHumanControlled())
   {
       IntendedAim = rotator((PC.Location + (PC.Velocity * 0.80) - WeaponComponent.GetPosition()));
       if(IntendedAim.Yaw < -16384 || IntendedAim.Yaw > 16384)
           IntendedAim.Pitch = -16384 - (16384 + IntendedAim.Pitch);

       //Incase the turret was rotated in the editor!
       IntendedAim = IntendedAim - Self.Rotation;
       CurrentAim = WeaponComponent.Rotation;

       if(IntendedAim.Pitch - CurrentAim.Pitch <= 1600 && IntendedAim.Pitch - CurrentAim.Pitch >= -1600)
       {
            CurrentAim.Pitch = IntendedAim.Pitch;
            WeaponComponent.SetRotation(CurrentAim);
            Super.Tick(DeltaTime);
       }
       if(IntendedAim.Pitch - CurrentAim.Pitch > 1600)
       {
            CurrentAim.Pitch += deltaTime * ROTATION_SPEED;
            WeaponComponent.SetRotation(CurrentAim);
       }
       if(IntendedAim.Pitch - CurrentAim.Pitch < -1600)
       {
            CurrentAim.Pitch -= deltaTime * ROTATION_SPEED;
            WeaponComponent.SetRotation(CurrentAim);
       }

       // Also done in super, but we dont always use super!
       HeadCollision.SetTranslation(vector(WeaponComponent.Rotation) * 22);
   }
}



defaultproperties
{
    bRotateClockWise = true
    bWaiting = false

    //Turret Type
    Begin Object Name=Proj
		ProjectileClass=class'BailterRayProj_Goo'
		MuzzleFlash=ParticleSystem'WP_BioRifle.Particles.P_WP_Bio_3P_MF'
		DeathEffect=ParticleSystem'WP_BioRifle.Particles.P_WP_Bio_Alt_Blob_POP'
		DeathSound = SoundCue'A_Weapon_BioRifle.Weapon.A_BioRifle_FireAltImpactExplode_Cue'
		FireSound = SoundCue'A_Character_BodyImpacts.BodyImpacts.A_Character_BodyImpact_GibLarge_Cue'
		FireInterval=.8
	End Object
	GooTurret=Proj
}